package com.ymt.common.tools;

import java.util.Calendar;
import java.util.Date;

public class CronUtils {
    public static String toCron(Date beginTime, Long delayTime) {
        Long nextScheduledTime = beginTime.getTime() + delayTime;

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(nextScheduledTime);

        int year = calendar.get(Calendar.YEAR);//获取年
        int month = calendar.get(Calendar.MONTH) + 1;//获取月份，0表示1月份
        int day = calendar.get(Calendar.DAY_OF_MONTH);//获取当前天数
        int time = calendar.get(Calendar.HOUR_OF_DAY);//获取当前小时
        int min = calendar.get(Calendar.MINUTE);//获取当前分钟

        //30 16 12 9 *
        return min + " " + time + " " + day + " " + month;
    }
}
